package com.njh.charges.controller.apis;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hos.entity.his.OrderBackfee;
import com.hos.entity.his.OrderBackfeeItem;
import com.hos.vo.Result;
import com.njh.charges.service.BackFeeService;
import com.njh.charges.service.HandleMedicineService;
import com.njh.charges.vo.AllOrderBackFeeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author ：njh
 * @date ：Created in 2023/12/15 17:24
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/charges/api/handleMedicine")
@Api(tags = "处方发药相关接口")
public class ApiHandleMedicineController {

    @Resource
    private HandleMedicineService handleMedicineService;

    @GetMapping("getChargedCareHistoryOnlyMedicinesByRegId/{regId}")
    @ApiOperation("根据挂号ID查询已支付的药品处方信息及详情")
    public Result getChargedCareHistoryOnlyMedicinesByRegId(@PathVariable String regId) {

        Map chargedCareHistoryOnlyMedicinesByRegId = handleMedicineService.getChargedCareHistoryOnlyMedicinesByRegId(regId);
        Result<Map> result = new Result<>(200, "查询成功", chargedCareHistoryOnlyMedicinesByRegId);

        return result;
    }

    @PostMapping("doMedicine")
    @ApiOperation("处方发药")
    public Result doMedicine(@RequestBody JSONArray array) {

        List list = JSONArray.parseArray(array.toJSONString());

        Integer integer = handleMedicineService.doMedicine(list);
        Result<Integer> result = new Result<>(200, "发药成功", integer);

        return result;
    }

}